package com.ruoyi.web.controller.datastatistics;

import java.io.IOException;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.basedata.domain.ElectricityAreaReport;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.basedata.domain.ElectricityAreaLine;
import com.ruoyi.basedata.service.IElectricityAreaLineService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 区域线损报表Controller
 * 
 * @author zt
 * @date 2025-03-12
 */
@RestController
@RequestMapping("/energy/lineLoss")
public class ElectricityAreaLineController extends BaseController
{
    @Autowired
    private IElectricityAreaLineService electricityAreaLineService;

    /**
     * 查询区域线损报表列表
     */
    @GetMapping("/list")
    public TableDataInfo list(ElectricityAreaLine electricityAreaLine)
    {
        startPage();
        List<ElectricityAreaLine> list = electricityAreaLineService.selectElectricityAreaLineList(electricityAreaLine);
        return getDataTable(list);
    }

    /**
     * 导出区域线损报表列表
     */
    @Log(title = "区域线损报表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ElectricityAreaLine electricityAreaLine) throws IOException {
        electricityAreaLineService.exportElectricityAreaLineList(response,electricityAreaLine);
    }

    /**
     * 获取区域线损报表详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(electricityAreaLineService.selectElectricityAreaLineById(id));
    }

    /**
     * 新增区域线损报表
     */
    @Log(title = "区域线损报表", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ElectricityAreaLine electricityAreaLine)
    {
        return toAjax(electricityAreaLineService.insertElectricityAreaLine(electricityAreaLine));
    }

    /**
     * 修改区域线损报表
     */
    @Log(title = "区域线损报表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ElectricityAreaLine electricityAreaLine)
    {
        return toAjax(electricityAreaLineService.updateElectricityAreaLine(electricityAreaLine));
    }

    /**
     * 删除区域线损报表
     */
    @Log(title = "区域线损报表", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(electricityAreaLineService.deleteElectricityAreaLineByIds(ids));
    }

    /**
    * @Description: 获取线损报表
    * @date: 2025/3/12 10:44
    * @author: zt
    */
    @GetMapping("/getLineLossReportList")
    public AjaxResult getLineLossReportList(ElectricityAreaLine electricityAreaLine)
    {
        Map<String,Object> resMap = electricityAreaLineService.getLineLossReportList(electricityAreaLine);
        return AjaxResult.success(resMap);
    }
}
